<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
    />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>{% block title %}{% endblock %}</title>
    <script src="//libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  </head>
  <body>
    {% block content %}{% endblock %}

    <script type="text/javascript">
      $(function () {
        $(".delete").click(function () {
          var message = $(this).attr("message") || "你确定要删除吗？";
          if (window.confirm(message)) {
            var requestUrl = $(this).attr("request-url");
            var location = $(this).attr("location") || "localPage";

            $.post(
              requestUrl,
              { _method: "delete" },
              function (responseData) {
                if (responseData.state == "ok") {
                  if (location == "localPage") {
                    window.location.reload();
                  } else {
                    window.location.href = location;
                  }
                }
              },
              "json"
            );
          }
          return false;
        });
      });
    </script>
  </body>
</html>